<?php
/**
 * Created by coder meng.
 * User: coder meng
 * Date: 2018/4/10 14:22
 */
namespace app\api\controller;
use cmf\controller\AdminBaseController;
use think\Db;
class AjaxController extends AdminBaseController{
    //验证编号
    public function check_code_js(){
        $encrypt=input('get.encrypt');
        if(!is_numeric($encrypt)){
            $this->error('商品编号应为数字类型！');
        }
        $info = Db::name('Goods')->where(['g_encrypt' => $encrypt])->find();
        if(!empty($info)){
            $this->error('该商品编号己存在！');
        }else{
            $this->success('该商品编号可以使用！');
        }
    }
    //验证名称
    public function check_name_js(){
        $name=input('get.name');
        $info = Db::name('Goods')->where(['g_goodsname' => $name])->find();
        if(!empty($info)){
            $this->error('该商品名称己存在！');
        }else{
            $this->success('该商品名称可以使用！');
        }
    }     
}